<%@page import="java.util.Map"%>
<%@page import="org.apache.commons.codec.binary.Base64"%>
<%@page import="java.util.Enumeration"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
	div.content{
		
	}
</style>
<title>test</title>
</head>
<body>
		<%
		  response.setHeader("Cache-Control","no-store"); 
		  response.setDateHeader("Expires",0); 
		  String temppass= request.getHeader("authorization"); 
		  if(temppass==null){
			  response.setStatus(401); 
			  response.setHeader("WWW-authenticate","Basic Realm=\"test\"");
			  return ;
		  } 
		  if ((temppass!=null)&&(temppass.length()>6)){ 
			  if ((temppass!=null)&&(temppass.length()>6)){ 
				  temppass= temppass.substring(6,temppass.length()); 
				  out.println("取出来的用户名字和密码base64code为："+temppass); 
				  String temppassdecode =  new String(Base64.decodeBase64(temppass.getBytes()));
				  out.println("<br/>解码的结果是："+temppassdecode); 
				  out.print("<br/>");
		 } 
		 }
		Enumeration e = request.getHeaderNames();
		while(e.hasMoreElements()){
			String name = (String)e.nextElement();
			String value = request.getHeader(name);
			out.print("headerName:"+name+" value:"+value);
			out.print("<br/>");
			System.out.println("headerName:"+name+" value:"+value);
		}
		Cookie[] cs =request.getCookies();
		if(cs!=null){
			for(Cookie c:cs){
				out.print("CookieName:"+c.getName()+" value:"+c.getValue());
				out.print("<br/>");
				System.out.println("CookieName:"+c.getName()+" value:"+c.getValue());
			}
		}
	/* 	e = request.getParameterNames();
		while(e.hasMoreElements()){
			String name = (String)e.nextElement();
			String value = request.getParameter(name);
			out.print("paramName:"+name+" value:"+value);
			out.print("<br/>");
			System.out.println("paramName:"+name+" value:"+value);
		} */
		Map<String,String[]> map = request.getParameterMap();
		for(Map.Entry<String,String[]> s:map.entrySet()){
			String name = s.getKey();
			String[] value = s.getValue();
			out.print("paramName:"+name+" value:"+value);
			out.print("<br/>");
			System.out.println("paramName:"+name+" value:"+value);
		}
		%>
		<div>content</div>
</body>
</html>